// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Layouts

import Fk
import Fk.Components.Common
import "../components/buttons" as QsgsButton

Item {
  property string box_type: "choice_box"
  property var options: []
  property var all_options: []
  property string skill_name: ""
  property int result

  signal accepted() //Read result
  signal finished() //Close the box

  id: root
  // title.text: Lua.tr("$Choice").arg(Lua.tr(skill_name))
  width: body.width
  height: body.height

  Row {
    id: body
    height: 32
    spacing: 20
    
    Repeater {
      model: all_options

      QsgsButton.AskToChoiceButton {
        height: body.height
        text: Util.processPrompt(modelData)
        enabled: options.indexOf(modelData) !== -1

        onClicked: {
          result = index;
          root.close();
        }
      }

    }
  }

  function close()
  {
    accepted();
    finished();
  }
}
